home *** CD-ROM | disk | FTP | other *** search
- /*
- File: BentoSuppress.h
-
- Contains: Definition of class to temporarily supress fatal Bento errors.
-
- Owned by: Douglas Hill
-
- Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <3> 8/19/96 DH 1376276:OD corrupts document when out of
- disk creating draft. Introduced TempCMValue
- class to properly set and reset usecount of
- values.
- <2> 8/13/96 DM 1376080: new class TempDelayBentoFatalError
- prevents fatal errors from being
- permanently disabled
- */
-
- #ifndef _BENTOSUPPRESS_
- #define _BENTOSUPPRESS_
-
- #ifndef _TEMPOBJ_
- #include "TempObj.h"
- #endif
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- #ifndef _CM_API_
- #include <CMAPI.h>
- #endif
-
- //------------------------------------------------------------------------------
- // TempSuppressFatalBentoError
- //------------------------------------------------------------------------------
-
- // Use this class to supress fatal Bento errors when making Bento API calls.
- // Since there is no Bento API for validating a file you wish to open, or that
- // creating a new container will fail, we need to make sure that we at least
- // won't crash in the process. Make sure that the scope of this object is only
- // for the Bento API calls you want to supress. Wrap the instantiation in braces
- // to create scope.
- //
- // For example,
- //
- // void foo(void) {
- // ....
- // Starts supressing Bento fatal errors.
- // {
- // TempSuppressFatalBentoError tempObj;
- //
- // BentoAPICall1( ...);
- // BentoAPICall2( ...);
- // }
- // ends supressing Bento fatal errors.
- // }
- extern ODBoolean gODSuppressBentoFatalError;
-
- class TempSuppressFatalBentoError /*d*/ : Destructo {
- public:
- TempSuppressFatalBentoError();
-
- virtual ~TempSuppressFatalBentoError();
-
- private:
- ODBoolean fOldSuppress;
- };
-
- //------------------------------------------------------------------------------
- // TempDelayBentoFatalError
- //------------------------------------------------------------------------------
-
- // Use this class to temporarily delay a fatal Bento error, when it would be very
- // bad to call ExitToShell(). For example, while in the drag manager, we do not
- // want to call ExitToShell() because this will wedge the machine.
-
- extern ODBoolean gODDelayBentoFatalError;
-
- class TempDelayBentoFatalError /*d*/ : Destructo {
- public:
- TempDelayBentoFatalError();
-
- virtual ~TempDelayBentoFatalError();
-
- private:
- ODBoolean fOldDelay;
- };
-
- //------------------------------------------------------------------------------
- // TempCMValue
- //------------------------------------------------------------------------------
-
- // This class ensures that refcounted Bento values get released.
-
- class TempCMValue /*d*/ : Destructo {
- private:
- CMValue fValue;
-
- public:
- TempCMValue(CMValue v) : fValue(v) { }
- TempCMValue();
-
- virtual ~TempCMValue();
-
- operator CMValue () { return fValue; }
- CMValue operator= (CMValue v) { fValue = v; return v; }
-
- CMValue DontRelease() { CMValue v = fValue; fValue = kODNULL; return v;}
- };
-
- #endif